import { defineStore } from "pinia"

// 管理员登录状态管理
export const useAdminStore = defineStore('admin', () => {
    const admin_id = ref(null);          // 管理员账号
    const admin_password = ref(null);    // 管理员密码

    function login(id, password) {
        // 保存属性
        admin_id.value = id;
        admin_password.value = password;
    }

    function logout() {
        // 清除属性
        admin_id.value = null;
        admin_password.value = null;
    }

    return {admin_id, admin_password, login, logout}
},
{
    persist: {
        storage: sessionStorage
    }
});